package com.huibo.aigou.controller;

import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import com.huibo.aigou.base.bo.AjaxResult;
import com.huibo.aigou.util.RedisUtil;

@RestController
@RequestMapping("/redis")
public class RedisController {
	
	@GetMapping("/get")
	public String get(@RequestParam("key") String key) {
		return RedisUtil.get(key);
	}
	
	@PostMapping("/set")
	public AjaxResult set(@RequestParam("key") String key,@RequestParam("value") String value) {
		try {
			RedisUtil.set(key, value);
			return AjaxResult.createInstance().setMsg("设置成功");
		}catch(Exception e) {
			e.printStackTrace();
			return AjaxResult.createInstance().setMsg("设置失败").setCode(500);
		}
	}

}
